import axios from 'axios';

axios.defaults.timeout = 5000;
axios.defaults.baseURL = '';

// 添加请求拦截器
axios.interceptors.request.use(
  (config) => config,
  (error) => Promise.reject(error),
);

// 添加响应拦截器
axios.interceptors.response.use(
  (response) => response,
  (error) => Promise.reject(error),
);
function handle(data) { // 返回数据统一处理
  return data;
}
function pwapost(url, params) {
  return new Promise((resovle, reject) => {
    axios({
      method: 'post',
      url: '',
      data: params,
    }).then((response) => {
      resolve(handle(response));
    }).catch((err) => {
      reject(err);
    });
  });
}
export default {
  pwapost,
};
